﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<GabageFactory.Models.Message>" %>
<%@ Import Namespace="System.Collections.Generic" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	发布通知
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div id="dolphincontainer">
	    <div id="dolphinnav">
	        <ul style="display:none;">
	            <li><a href="/Message/Index"><span>通知管理</span></a></li>
                <li><a href="javascript:return(false);" class="current"><span>发布通知</span></a></li>
	        </ul>
	    </div>
	</div>

    <% 
        User user = (User)ViewData["user"];
        using (Html.BeginForm())
    {%>
        <%= Html.ValidationSummary(true) %>
        <%= Html.HiddenFor(model => model.Id) %>
            
    <table cellpadding="4" cellspacing="0" class="com_detail_table" style="width:956px;">
        <tr>
            <th colspan="2">创建通知</th>
        </tr>
        
        <tr>
            <td class="lab" style="width:80px;">所属公司：</td>
            <%if (user.RoleId == (int)RoleEnum.Administrator || user.RoleId == (int)RoleEnum.Expert) { %>
            <td>
                <%= Html.DropDownList("FactoryId", ViewData["factories"] as List<SelectListItem>, "请选择公司")%>
                <%= Html.ValidationMessageFor(model => model.FactoryId)%>
            </td>
            <%
              }
              else
              { 
            %>
            <td>
                <%= user.Factory.Name%>
                <%= Html.Hidden("FactoryId", user.FactoryId) %>
            </td>
            <%
              }
            %>
        </tr>
        <tr>
           <td class="lab">通知类型：</td>
           <td>
                <select name="type">
                    <option>请选择类型</option>
                    <option value="1" <%if(Model.type == 1){ %> selected="selected" <%} %>>公司重要通知</option>
                    <option value="2" <%if(Model.type == 2){ %> selected="selected" <%} %>>监控信息通知</option>
                    <option value="3" <%if(Model.type == 3){ %> selected="selected" <%} %>>系统维护通知</option>
                </select>
                <%= Html.ValidationMessageFor(model => model.type)%>
           </td>
        </tr>
        <tr>
           <td class="lab">优先级：</td>
           <td>
                <%= Html.DropDownList("priority", ViewData["priorities"] as List<SelectListItem>, "请选择优先级")%>
                <%= Html.ValidationMessageFor(model => model.priority)%>
           </td>
        </tr>
        <tr>
           <td class="lab">阅读人员：</td>
           <td>
                <input id="allRole" type="checkbox" name="roles" onclick="checkAll();" value="0" <%if (string.IsNullOrEmpty(Model.roles) || Model.roles == "0") {%>checked="checked" <%} %> /> 所有人员
                <input type="checkbox" name="roles" onclick="uncheckAll();" value="2" <%if (!string.IsNullOrEmpty(Model.roles) && Model.roles.Contains("2")) {%>checked="checked" <%} %> /> 录入人员
                <input type="checkbox" name="roles" onclick="uncheckAll();" value="3" <%if (!string.IsNullOrEmpty(Model.roles) && Model.roles.Contains("3")) {%>checked="checked" <%} %> /> 监控负责人
                <input type="checkbox" name="roles" onclick="uncheckAll();"  value="6" <%if (!string.IsNullOrEmpty(Model.roles) && Model.roles.Contains("6")) {%>checked="checked" <%} %> /> 管理人员
                <%if (user.RoleId == (int)RoleEnum.Administrator || user.RoleId == (int)RoleEnum.Expert) { %>
                <input type="checkbox" name="roles" onclick="uncheckAll();"  value="4" <%if (!string.IsNullOrEmpty(Model.roles) && Model.roles.Contains("4")) {%>checked="checked" <%} %> /> 分析人员
                <input type="checkbox" name="roles" onclick="uncheckAll();"  value="5" <%if (!string.IsNullOrEmpty(Model.roles) && Model.roles.Contains("5")) {%>checked="checked" <%} %> /> 系统管理员
                <input type="checkbox" name="roles" onclick="uncheckAll();"  value="7" <%if (!string.IsNullOrEmpty(Model.roles) && Model.roles.Contains("7")) {%>checked="checked" <%} %> /> 专家
                <%} %>
                <%= Html.ValidationMessageFor(model => model.roles)%>
           </td>
        </tr>
        <tr>
           <td class="lab">开始时间：</td>
           <td>
                <%= Html.TextBoxFor(model => model.beginTime, new { @readonly = "readonly"})%>
                <%= Html.ValidationMessageFor(model => model.beginTime) %>
           </td>
        </tr>
        <tr>
           <td class="lab">结束时间：</td>
           <td>
                <%= Html.TextBoxFor(model => model.endTime, new { @readonly = "readonly"})%>
                <%= Html.ValidationMessageFor(model => model.endTime) %>
           </td>
        </tr>
        <tr>
           <td class="lab">通知内容：</td>
           <td>
                <%= Html.TextAreaFor(model => model.content, new { cols=50, rows=10, id="CKEditor1"})%>
                <%= Html.ValidationMessageFor(model => model.content) %>
           </td>
        </tr>
    </table>
    
    <div class="submit_btn_area" style="margin-left:112px;">
        <input type="submit" value="提 交" />
    </div>
    <% } %>

    <script type="text/javascript">
        window.CKEDITOR_BASEPATH = '/ckeditor/';
    </script>
    <script src="../../ckeditor/ckeditor.js" type="text/javascript"></script>
    <script type="text/javascript">
        var CKEditor_Controls = [], CKEditor_Init = [];
        function CKEditor_TextBoxEncode(d, e) {
            var f;
            if (typeof CKEDITOR == 'undefined' || typeof CKEDITOR.instances[d] == 'undefined') {
                f = document.getElementById(d);
                if (f) f.value = f.value.replace(/</g, '&lt;').replace(/>/g, '&gt;');
            } else {
                var g = CKEDITOR.instances[d];
                if (e && (typeof Page_BlockSubmit == 'undefined' || !Page_BlockSubmit)) {
                    g.destroy();
                    f = document.getElementById(d);
                    if (f) f.style.visibility = 'hidden';
                }
                else g.updateElement();
            } 
        }; 
        (function () { if (typeof CKEDITOR != 'undefined') { var d = document.getElementById('CKEditor1'); if (d) d.style.visibility = 'hidden'; } var e = function () { var f = CKEditor_Controls, g = CKEditor_Init, h = window.pageLoad, i = function () { for (var j = f.length; j--; ) { var k = document.getElementById(f[j]); if (k && k.value && (k.value.indexOf('<') == -1 || k.value.indexOf('>') == -1)) k.value = k.value.replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&amp;/g, '&'); } if (typeof CKEDITOR != 'undefined') for (var j = 0; j < g.length; j++) g[j].call(this); }; window.pageLoad = function (j, k) { if (k.get_isPartialLoad()) setTimeout(i, 0); if (h && typeof h == 'function') h.call(this, j, k); }; if (typeof Page_ClientValidate == 'function' && typeof CKEDITOR != 'undefined') Page_ClientValidate = CKEDITOR.tools.override(Page_ClientValidate, function (j) { return function () { for (var k in CKEDITOR.instances) { if (document.getElementById(k)) CKEDITOR.instances[k].updateElement(); } return j.apply(this, arguments); }; }); setTimeout(i, 0); }; if (typeof Sys != 'undefined' && typeof Sys.Application != 'undefined') Sys.Application.add_load(e); if (window.addEventListener) window.addEventListener('load', e, false); else if (window.attachEvent) window.attachEvent('onload', e); })(); CKEditor_Controls.push('CKEditor1');
        CKEditor_Init.push(function () { if (typeof CKEDITOR.instances['CKEditor1'] != 'undefined' || !document.getElementById('CKEditor1')) return; CKEDITOR.replace('CKEditor1', { "htmlEncodeOutput": true, "removePlugins": "elementspath", "toolbar": [["Undo", "Redo"], ["Bold", "Italic", "Underline", "Strike", "-", "Subscript", "Superscript"], ["JustifyLeft", "JustifyCenter", "JustifyRight", "JustifyBlock"], ["Styles", "Format", "Font", "FontSize"], ["TextColor", "BGColor"]] }); });
        
    </script>

    <script type="text/javascript" language="javascript">
        $('#beginTime').datetimepicker({
            showSecond: true,
            timeFormat: 'hh:mm:ss'
        });

        $('#endTime').datetimepicker({
            showSecond: true,
            timeFormat: 'hh:mm:ss'
        });

        function checkAll() {
            $("input[name='roles']").each(function(){$(this).prop("checked", false);});
            $("#allRole").prop("checked", true);
        }

        function uncheckAll() {
            $("#allRole").prop("checked", false);
        }
    </script>
</asp:Content>
